import { apiGet, apiPost, apiPut, apiDelete } from './client'

export interface CourseOffering {
  id?: number
  courseId?: number
  termId?: number
  classId?: number
  teacherId?: number
}

export async function listOfferings(params: { courseId?: number; termId?: number; classId?: number; offset?: number; limit?: number } = {}) {
  return apiGet<CourseOffering[]>('/api/grades/course-offerings', params)
}

export async function getOffering(id: number) {
  return apiGet<CourseOffering>(`/api/grades/course-offerings/${id}`)
}

export async function createOffering(offering: CourseOffering) {
  return apiPost<CourseOffering>('/api/grades/course-offerings', offering)
}

export async function updateOffering(id: number, offering: CourseOffering) {
  return apiPut<CourseOffering>(`/api/grades/course-offerings/${id}`, offering)
}

export async function deleteOffering(id: number) {
  return apiDelete<string>(`/api/grades/course-offerings/${id}`)
}